using Microsoft.AspNetCore.Mvc;

using System.Buffers.Text;

namespace PaddleOCRWebAPI.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class PaddleOCRController : ControllerBase
    {
        [HttpPost("DetectText")]
        public  string DetectText([FromBody] string base64)
        {
            try
            {
                DateTime dt1 = DateTime.Now;
                var result = PaddleOCRHelper.Instance.DetectTextBase64(base64);
                DateTime dt2 = DateTime.Now;
                Console.WriteLine((dt2-dt1).TotalMilliseconds+"ms");
                Console.WriteLine(result.Text);
                return result.Text;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return "";
            }
           
        }

    }
}